﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl wvru a" xmlns:wvru="http://schemas.datacontract.org/2004/07/Woodbase.CodeBase.WVR.Objects" xmlns:a="http://schemas.datacontract.org/2004/07/Woodbase.CodeBase.WVR.Objects">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="ArrayOfUser">
      <xsl:apply-templates select="User">
        <xsl:sort select="LastName" order="ascending" />
      </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="User">
    <xsl:param name="isActive">
      <xsl:choose>
        <xsl:when test="@active = 'true'">
          #00FF00;
        </xsl:when>
        <xsl:otherwise>
          #C80000
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:param name="isActiveImage">
      <xsl:choose>
        <xsl:when test="Active = 'true'">075830-3d-glossy-blue-orb-icon-business-lock4.png</xsl:when>
        <xsl:otherwise>075827-3d-glossy-blue-orb-icon-business-lock1.png</xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:param name="isActiveTitle">
      <xsl:choose>
        <xsl:when test="@active = 'true'">Active</xsl:when>
        <xsl:otherwise>Inactive</xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <table class="clienttable ui-draggable">
      <tr>
        <td style="width:24px; height:24px; background-color:{$isActive};" title="{$isActiveTitle} user" >
          <img src="/Images/design/{$isActiveImage}" alt="{$isActiveTitle}" style="width:32px;" />
        </td>
        <td class="username">
          <label id="{@user-id}"></label>
          <xsl:value-of select="@givenname" /><xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;<xsl:value-of select="@lastname" />
        </td>
      </tr>
      <tr>
            <xsl:choose>
              <xsl:when test="@blacklisted = 'false'">
                <td style="background-color:#00FF00;">
                  <img src="/Images/design/075891-3d-glossy-blue-orb-icon-business-thumbs-up.png" style="width:32px;" alt="Users is OK" />
                </td>
                <td>
                Not<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;blacklisted
                </td>
              </xsl:when>
              <xsl:otherwise>
                <td style="background-color:#C80000;">
                  <img src="/Images/design/075889-3d-glossy-blue-orb-icon-business-thumbs-down1.png" style="width:32px;" alt="User is blacklisted" />
                </td>
                <td>
                  Blacklisted
                </td>
              </xsl:otherwise>
            </xsl:choose>
      </tr>
      <xsl:if test="count(.//movies/@title)>0">
        <tr>
          <td style="text-align:center;">
            <img src="/Images/design/information.png" alt="This user has movies" />
          </td>
          <td>Rented movies: <span class="rentedMoviesCount"><xsl:value-of select="count(.//movies/@title)" /></span>
        </td>
        </tr>
      </xsl:if>
    </table>
  </xsl:template>
</xsl:stylesheet>